package squareBorderPackage;

import static org.junit.Assert.*;

import java.math.BigDecimal;

import org.junit.*;

import temperaturePackage.*;

/**
 * A class collection tests for the class of walls.
 * 
 * @version	1.0
 * @author 	Jessa Bekker & Esther Alberts
 */
public class WallTest {
	
	/**
	 * Instance variable referencing walls that may change during individual
	 * tests.
	 */
	private Wall wall, slipperyWall;
	
	/**
	 * Instance variable referencing squares that may change during individual
	 * tests.
	 */
	private Square defaultSquare1, defaultSquare2, defaultSquare3, defaultSquare4;
	
	@Before
	public void setUp() {
		defaultSquare1 = new NormalSquare();
		defaultSquare2 = new NormalSquare(new Temperature(45, TemperatureUnit.CELSIUS),new BigDecimal(45));
		defaultSquare3 = new NormalSquare();
		defaultSquare4 = new NormalSquare();
		wall = new Wall(false, defaultSquare1, Direction.SOUTH);
		wall.attachTo(defaultSquare2, Direction.NORTH);
		slipperyWall = new Wall(true, defaultSquare3, Direction.SOUTH);
		slipperyWall.attachTo(defaultSquare4, Direction.NORTH);
		
	}
	
	@Test
	public void getSlippery_True() {
		assertTrue(slipperyWall.getSlippery());
	}
	
	@Test
	public void getSlippery_False() {
		assertFalse(wall.getSlippery());
	}
	
	@Test
	public void isObstacle_LegalCase() {
		assertTrue(wall.isObstacle());
	}
	
	@Test
	public void getStrongestBorder_DoorNull() {
		assertTrue(wall.getStrongestBorder(null)
		instanceof Wall);
	}

	@Test
	public void getStrongestBorder_DoorOpenBorder() {
		assertTrue(wall.getStrongestBorder(new OpenBorder(defaultSquare1, Direction.WEST))
		instanceof Wall);
	}
	
	@Test
	public void getStrongestBorder_DoorDoor() {
		assertTrue(wall.getStrongestBorder(new Door(true, defaultSquare1, Direction.EAST))
		instanceof Wall);
	}
	
	@Test
	public void getStrongestBorder_DoorWall() {
		assertTrue(wall.getStrongestBorder(new Wall(true, defaultSquare1, Direction.FLOOR))
		instanceof Wall);
	}
	
	@Test
	public void split_notSlippery() {
		Wall[] newWalls = wall.split();
		assertTrue(newWalls[0].getSquareAt(Direction.SOUTH) == defaultSquare1);
		assertTrue(newWalls[0].getSquareAt(Direction.NORTH) == null);
		assertTrue(newWalls[1].getSquareAt(Direction.NORTH) == defaultSquare2);
		assertTrue(newWalls[1].getSquareAt(Direction.SOUTH) == null);
		assertFalse(newWalls[0].getSlippery());
		assertFalse(newWalls[1].getSlippery());
	}
	
	@Test
	public void split_slippery() {
		Wall[] newWalls = slipperyWall.split();
		assertTrue(newWalls[0].getSquareAt(Direction.SOUTH) == defaultSquare3);
		assertTrue(newWalls[0].getSquareAt(Direction.NORTH) == null);
		assertTrue(newWalls[1].getSquareAt(Direction.NORTH) == defaultSquare4);
		assertTrue(newWalls[1].getSquareAt(Direction.SOUTH) == null);
		assertTrue(newWalls[0].getSlippery());
		assertTrue(newWalls[1].getSlippery());
	}
}
